/**
* 版权声明：厦门睿商网络科技有限公司 版权所有 违者必究
* 日    期：2020-11-11
*/
package com.rzico.picture.entity;

import com.rzico.annotation.IgnoreSwaggerParameter;
import lombok.Data;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import javax.persistence.*;
import io.swagger.annotations.ApiModelProperty;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;

/**
 * <pre>
 *   素材管理数据库对象
 * </pre>
 * @author Rzico Boot
 * @version 1.0
 */
@Data
@JsonIgnoreProperties(value = {"handler"})
@JsonInclude(JsonInclude.Include.NON_NULL)
@Table(name = "wx_picture_category")
public class PictureCategory{

    @ApiModelProperty(value = "")
    @Id
    protected Long id;

    @ApiModelProperty(value = "创建日期")
    protected java.util.Date createDate;

    @ApiModelProperty(value = "修改日期")
    protected java.util.Date modifyDate;

    @ApiModelProperty(value = "排序")
    protected Integer orders;

    @ApiModelProperty(value = "名称")
    protected String name;

    @ApiModelProperty(value = "树路径")
    protected String treePath;

    @ApiModelProperty(value = "")
    protected Long parentId;

    @ApiModelProperty(value = "缩略图")
    protected String thumbnail;

    @ApiModelProperty(value = "创建者")
    protected String createBy;

    @ApiModelProperty(value = "更新者")
    protected String modifyBy;

    @ApiModelProperty(value = "子分类数组" ,hidden = true )
    @IgnoreSwaggerParameter
    private List<PictureCategory> childrens = new ArrayList<PictureCategory>();

    /**
     * 当前对象的直属父级
     */
    @JsonIgnore
    @IgnoreSwaggerParameter
    private PictureCategory parent;

    @ApiModelProperty(value = "上级分类名称", hidden = true)
    public String getParentName(){
        PictureCategory pictureCategory = getParent();
        if (null != pictureCategory){
            return pictureCategory.getName();
        }else{
            return "";
        }
    }

}
